#include <iostream>

using namespace std;
#define int long long
const int N = 1e3 + 10;
int n, h, r;
int x[N], y[N], z[N];
int fa[N];

int find(int x)
{
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

void merage(int x, int y)
{
    fa[find(x)] = find(y);
}
bool check(int i, int j)
{
    int d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]);
    return d <= 4 * r * r;
}
signed main()
{
    int T; cin >> T;
    while(T--)
    {
        cin >> n >> h >> r;
        for(int i = 0;i <= n + 1;i ++) fa[i] = i;
        
        for(int i = 1;i <= n;i ++)
        {
            cin >> x[i] >> y[i] >> z[i];
            //下面是否相切
            if(z[i] <= r) merage(0 , i);
            if(z[i] + r >= h) merage(n + 1 , i);

            for(int j = 1;j < i;j ++)
            {
                if(check(i , j)) merage(i , j);
            }
        }
        if(find(0) == find(n + 1)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}